package com.springboot.controller;

import com.springboot.model.User;
import com.springboot.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: TongRui乀
 * @Date: 2020-04-06 15:08
 * @description：
 */
@Slf4j
@RestController
@RequestMapping("user")
public class UserController {

    @Autowired
    private UserService userService;


    /**
     *  插入一条记录
     */
    @PostMapping("insert")
    public void insert(User user){

        this.userService.insert(user);
    }

    /**
     *  查询记录
     */
    @GetMapping("getUserById")
    public User getUserById(Integer id){

        User user = this.userService.getByUserId(id);

        return user;
    }


    /**
     *  修改记录
     */
    @PostMapping("update")
    public void update(User user){

        this.userService.updateByUserId(user);
    }


}
